import "./datatype/enum";
import "./datatype/interface";

// 基本数据类型
let str: string = "123";
let num: number = 123;
let bool: boolean = false;

// 数组
let arr: number[] = [1, 2, 3];
let arr2: Array<string> = ['1', '2', '3']

// 元组
let tuple: [number, number, number] = [1, 2, 3]

// 函数
let add = (x: number, y: number) => x + y;
let addFun: (x: number, y: number) => string;
addFun = (a, b) => a + '' + b;
addFun(2, 3);

// 对象
let obj: object = {name: 'zhangsan', age: 34, address: 'shenzhen'};
let obj2: {x: number, y: string} = {x: 12, y: 'lisifu'};
obj2.x = 32;


// symbol
let sym: symbol = Symbol();
let sym2 = Symbol()

// undefined 和 null
let nu: undefined = undefined;
let nul: null = null;

/*
 * undefined和null是基本类型的子类型，当一个值可以赋值给基本类型时，它也可以被赋值为undefined和null，
 * 需要在tsconfig.json文件中配置 "strictNullChecks": false,
 */ 
// let nums: number = 123;
// nums = null

// any
let x
x = 123;
x = "123";
x = true;
x = [1, 2, 3];
x = () => {};

// never 永远不会有返回值的类型
let error = () => {
  return new Error()
}

// 联合类型
let reser: number | string | boolean = "abcdefg";
console.log(reser, "reser");